package com.asiainfo.work.controller;

import com.asiainfo.work.request.zentao.TaskRequest;
import com.asiainfo.work.service.second.ZtTaskService;
import com.asiainfo.work.utils.BaseController;
import com.asiainfo.work.utils.BaseResponse;
import com.asiainfo.work.utils.PageResponse;
import com.asiainfo.work.vo.TaskActualTimeStatistics;
import com.asiainfo.work.vo.TaskClosedActualTimeStatistics;
import com.asiainfo.work.vo.TaskClosedStatistics;
import com.asiainfo.work.vo.TaskEsTimeStatistics;
import com.asiainfo.work.vo.TaskStatistics;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  controller
 * </p>
 *
 * @author baifan
 * @date 2021-01-05
 */
@RestController
@RequestMapping("/zt/task")
@Validated
@Slf4j
@Api(value = "ZtTaskController", tags = {"禅道任务管理"})
public class ZtTaskController extends BaseController{

    @Autowired
    private ZtTaskService ztTaskService;

    /**
     * 查询禅道用户任务数
     * @param taskRequest 查询条件
     * @return 分页返回任务数
     */
    @PostMapping("queryTask")
    @ApiOperation(value = "禅道用户任务数", notes = "禅道用户任务数", httpMethod = "POST")
    public BaseResponse<PageResponse<TaskStatistics>> queryTask(@RequestBody TaskRequest taskRequest){
        return ztTaskService.queryTask(taskRequest);
    }

    /**
     * 禅道任务工时统计接口
     * @param taskRequest  查询条件
     * @return 分页返回任务数
     */
    @PostMapping("queryTaskEsTime")
    @ApiOperation(value = "禅道任务工时统计", notes = "禅道任务工时统计", httpMethod = "POST")
    public BaseResponse<PageResponse<TaskEsTimeStatistics>> queryTaskEsTime(@RequestBody TaskRequest taskRequest){
        return ztTaskService.queryTaskEsTime(taskRequest);
    }

    /**
     * 禅道任务完成数接口
     * @param taskRequest  查询条件
     * @return 分页返回任务数
     */
    @PostMapping("queryTaskClosed")
    @ApiOperation(value = "禅道任务完成数", notes = "禅道任务完成数", httpMethod = "POST")
    public BaseResponse<PageResponse<TaskClosedStatistics>> queryTaskClosed(@RequestBody TaskRequest taskRequest){
        return ztTaskService.queryTaskClosed(taskRequest);
    }

    /**
     * 禅道用户完成任务所用实际工时
     * @param taskRequest  查询条件
     * @return 分页返回任务数
     */
    @PostMapping("queryTaskClosedActualTime")
    @ApiOperation(value = "禅道用户完成任务所用实际工时", notes = "禅道用户完成任务所用实际工时", httpMethod = "POST")
    public BaseResponse<PageResponse<TaskClosedActualTimeStatistics>> queryTaskClosedActualTime(@RequestBody TaskRequest taskRequest){
        return ztTaskService.queryTaskClosedActualTime(taskRequest);
    }

    /**
     * 禅道用户开发所用实际工时
     * @param taskRequest  查询条件
     * @return 分页返回任务数
     */
    @PostMapping("queryTaskActualTime")
    @ApiOperation(value = "禅道用户开发所用实际工时", notes = "禅道用户开发所用实际工时", httpMethod = "POST")
    public BaseResponse<PageResponse<TaskActualTimeStatistics>> queryTaskActualTime(@RequestBody TaskRequest taskRequest){
        return ztTaskService.queryTaskActualTime(taskRequest);
    }


}
